package ui;

import define.Common;
import define.ErrorDefine;
import main.ErrorException;
import main.ErrorHandler;
import excelBase.ExcelData;

public class OutputThread extends Thread
{
	public static OutputThread m_instance;
	
	public void run()
	{
		try 
		{
			Window.m_instance.setButtonGo(true);
			Common.m_isRunning = true;
			ExcelData.output();
			Window.m_instance.addText("output finish");
		} 
		catch (ErrorException e) 
		{
			new ErrorHandler(e);
		}		
		finally
		{
			Window.m_instance.setButtonGo(false);
			Common.m_isRunning = false;
		}
	}
	
	public void hang(int position) throws ErrorException
	{
		synchronized(this) 
		{
			try 
			{
				this.wait();
			} 
			catch (Exception e)
			{
				this.notify();
				throw new ErrorException(ErrorDefine.E_CANT_PAUSE_ERROR, position);
			}
		}
	}
}
